<?php
/************************FoxPHP威客系统************************/
/*                                                            */
/*  FoxPHP.Com (C)2006-2016 FoxPHP Inc.                       */
/*  This is NOT a freeware, use is subject to license terms   */
/*  FoxPHP威客系统是商业软件,使用于商业用途请购买授权         */
/*  V3.0 2016.3                                               */
/*  foxphp@aliyun.com                                         */
/*  http://www.foxphp.com                                     */
/*                                                            */
/**************************************************************/

namespace Post\Controller;
$_POST['datatype']='json';
class DialogController extends \Member\Controller\IndexController {

	//消息地址------------------------------------------------------------------------------------/
	//消息地址插入
	//地址 /post/dialog/insert
	public function insertAction(){
		if(intval($_GET['mobile'])){
			//移动
		}else{
			if(IsPost('Submit')){
				//模块
				$model=new \Member\Model\MemberDialogModel();
				//检查默认
				$user=$model->CheckDefaultData();
				if(!$user['touid']){
					$this->ajaxReturn(array('title'=>'提示','message'=>$model->getError(),'status'=>'error'),$_POST['datatype']);
					return false;
				}
				
				$result=$model->InsertDialogData($user);
				$this->ajaxReturn(array('title'=>'操作成功','message'=>'发送成功!','status'=>'ok','refresh'=>true),$_POST['datatype']);
			}else{
				$this->ajaxReturn(array('title'=>'验证失败','message'=>'没有数据提交！'.$result,'status'=>'error'),$_POST['datatype']);
			}
		}
	}
	
	//消息地址删除
	//地址 /post/dialog/delete
	public function deleteAction(){
		if(intval($_GET['mobile'])){
			//移动
		}else{
			if(IsPost('Submit')){
				//模块
				$model=new \Member\Model\MemberDialogModel();
				$result=$model->DeleteDialogData();
				$this->ajaxReturn(array('title'=>'删除成功','message'=>'删除成功!','status'=>'ok','refresh'=>true,'url'=>''),$_POST['datatype']);
			}else{
				$this->ajaxReturn(array('title'=>'验证失败','message'=>'没有数据提交！'.$result,'status'=>'error'),$_POST['datatype']);
			}
		}
	}
	
	//消息地址------------------------------------------------------------------------------------ end/
	
	
	//IM用户
	//地址 /post/dialog/getuser
	public function getuserAction(){
		if(intval($_GET['mobile'])){
			//移动
		}else{
		
			$model=new \Member\Model\MemberDialogModel();
			$result=$model->GetUserIm();
			$this->ajaxReturn(array('title'=>'获取成功','message'=>'获取成功!','status'=>'ok','refresh'=>true,'data'=>$result,'myavatar'=>GetAvatarSimple($this->uid,48,'comment-avatar')),$_POST['datatype']);
		}
	}
	
	//IM对话
	//地址 /post/dialog/getchat
	public function getchatAction(){
		if(intval($_GET['mobile'])){
			//移动
		}else{
		
			$model=new \Member\Model\MemberDialogMessageModel();
			$result=$model->GetChatIm();
			$this->ajaxReturn(array('title'=>'获取成功','message'=>'获取成功!','status'=>'ok','refresh'=>true,'data'=>$result),$_POST['datatype']);
		}
	}

}